// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import VueTouch from 'vue-touch' // 引入插件
Vue.use(VueTouch, {name: 'v-touch'}) // 全局注册
import 'lib-flexible/flexible'  //这个插件使用来px 转 rem

import './assets/mui/css/mui.min.css'
import './gloabl/style.css'
global.url = {
	'graphql' : 'graphql/',
	'target_file' : process.env.API_HOST+'target_file/',
	'img_path' : process.env.API_HOST+'operation_media/',
	'file_path': process.env.API_HOST+'operation_media/',
}

import axios from 'axios'
const API_HOST = process.env.API_HOST
axios.defaults.headers.post["Content-type"] = "application/json"
axios.defaults.baseURL = API_HOST
axios.defaults.retry = 4;
axios.defaults.retryDelay = 5000;
axios.interceptors.response.use(undefined, function axiosRetryInterceptor(err) {
    var config = err.config;
    // If config does not exist or the retry option is not set, reject
    if(!config || !config.retry) return Promise.reject(err);
    
    // Set the variable for keeping track of the retry count
    config.__retryCount = config.__retryCount || 0;
    
    // Check if we've maxed out the total number of retries
    if(config.__retryCount >= config.retry) {
        // Reject with the error
        return Promise.reject(err);
    }
    
    // Increase the retry count
    config.__retryCount += 1;
    
    // Create new promise to handle exponential backoff
    var backoff = new Promise(function(resolve) {
        setTimeout(function() {
            resolve();
        }, config.retryDelay || 1);
    });
    
    // Return the promise in which recalls axios to retry the request
    return backoff.then(function() {
        return axios(config);
    });
});
Vue.prototype.$http=axios

import Common from './gloabl/util.js'
Vue.use(Common)

import './assets/font/iconfont.css' //加载自定义图标

Vue.config.productionTip = false

document.addEventListener('touchstart', function(event) {
    // 判断默认行为是否可以被禁用
    if (event.cancelable) {
        // 判断默认行为是否已经被禁用
        if (!event.defaultPrevented) {
            event.preventDefault();
        }
    }
}, false);

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
